IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'USER')
BEGIN
    DROP TABLE [dbo].[USER]
END

GO

CREATE TABLE [dbo].[USER] ( 
	[ID]			INT IDENTITY(1,1)   NOT FOR REPLICATION     NOT NULL,
	[LOGIN]         VARCHAR(256)        NOT NULL	UNIQUE,
    [NAME]          VARCHAR(256),
    [SURNAME]       VARCHAR(256),
    [MIDDLE_NAME]   VARCHAR(256),
    [EMAIL]         VARCHAR(256)        NOT NULL	UNIQUE,
    [TEL_NUMBER]    VARCHAR(256),
    [INFORMATION]   VARCHAR(MAX),
	[PASSWORD]      VARCHAR(256)    	NOT NULL,
	[ROLE_ID]       INT

    CONSTRAINT [PK_USER_ID] PRIMARY KEY CLUSTERED ( 
        [ID] 
    ) ON [PRIMARY],
    
    CONSTRAINT [FK_USER_ROLE_ID] FOREIGN KEY ( 
        [ROLE_ID]
    ) REFERENCES [dbo].[ROLE] (
        [ID]
    )
    
) ON [PRIMARY] 

CREATE INDEX [IDX_USER_LOGIN_PASSWORD] on [dbo].[USER] ([LOGIN],[PASSWORD]) 

GO